package satir.framework;

/**
 * The Class InputValidator.
 * @version 3.0 April 2012
 * @author Creative Family
 */
public final class InputValidator {

    /**
     * Instantiates a new input validator.
     */
    private InputValidator() {
    }

    /**
     * Checks if is integer.
     * @param input the input
     * @return true, if is integer
     */
    public static boolean isInteger(final String input) {
	try {
	    Integer.parseInt(input);
	    return true;
	} catch (NumberFormatException e) {
	    return false;
	}
    }

    /**
     * Checks if is double.
     * @param input the input
     * @return true, if is double
     */
    public static boolean isDouble(final String input) {
	try {
	    Double.parseDouble(input);
	    return true;
	} catch (NumberFormatException e) {
	    return false;
	}
    }

    /**
     * Checks if is within range.
     * @param input the input
     * @param upper the upper
     * @param lower the lower
     * @return true, if is within range
     */
    public static boolean isWithinRange(final int input, final int upper, final int lower) {
	return input >= upper && input <= lower;
    }

    /**
     * Checks if is character.
     * @param input the input
     * @return true, if is character
     */
    public static boolean isCharacter(final String input) {
	return input.length() == 1;
    }
}
